<script>
function throwit() {
  throw new Error('error');
}

function catchit() {
  try {
    throwit();
  } catch(e) {
	alert('msg:' + e.message + ', stack: ' + e.stack);
  }
}

catchit();
</script>